package com.hjxy.codetools.controller;

import com.hjxy.codetools.interfa.TuserServiceInterface;
import com.hjxy.codetools.model.TuserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "api/website")
public class TuserController {
    @Autowired
    TuserServiceInterface tuserServiceInterface;
    /**
     * 后台管理系统登陆接口
     * @param queryItem
     * @return
     * @throws Exception
     */
    @PostMapping(value = "login")
    public Map<String, Object> login(@RequestBody Map<String, String> queryItem) throws Exception {


        Map<String, Object> resultMap = new HashMap<>();

        if ("login".equals(queryItem.get("oper"))){
            Map whMap=new HashMap();
            whMap.put("tname",queryItem.get("username"));
            whMap.put("pass", queryItem.get("password"));
            whMap.put("usertype", 2);
            List<TuserModel> tuserModel = tuserServiceInterface.getTuserByItem(whMap);
            if (tuserModel!=null&&tuserModel.size()>0)
                resultMap.put("code", 20000);
            else
                resultMap.put("code", 40000);
        }

        return resultMap;
    }

}
